package com.icoopoo.modules.pagehelper.web;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.icoopoo.modules.pagehelper.modules.PageHelperModel;
import com.icoopoo.modules.pagehelper.service.PageHelperService;
import com.icoopoo.utils.resultResponse.HelperResponse;

@Controller
@RequestMapping("pageHelper")
public class PageHelperController {
	
	@Autowired
	private PageHelperService pageHelperService;
	
	@ResponseBody
	@RequestMapping(value = "/pageHelper",method = RequestMethod.GET)
	public Map<String, Object> PageHelper(HttpServletRequest request, HttpServletResponse response,String id) {
		List<PageHelperModel> list = null;
		try{
			if("1".equals(id)){
				list = pageHelperService.findPageHelperModels1();
			}else if("2".equals(id)){
				list = pageHelperService.findPageHelperModels2();
			}else if("3".equals(id)){
				list = pageHelperService.findPageHelperModels3();
			}else if("4".equals(id)){
				list = pageHelperService.findPageHelperModels4();
			}else if("5".equals(id)){
				list = pageHelperService.findPageHelperModels5();
			}
			System.out.println(list);
		}catch(Exception e){
			return HelperResponse.errorObject(null);
		}
		return HelperResponse.successObject(list);
	}

}
